/*
 * @Descripttion:
 * @Author: voanit
 * @Date: 2022-05-11 15:57:15
 * @LastEditors: voanit
 * @LastEditTime: 2022-05-12 09:55:36
 */
import React from 'react'
// import store from '../../store'

import { useSelector, useDispatch } from 'react-redux'

const Uncle = () => {
  /* 对任务进行派发 */
  const dispatch = useDispatch()
  /* 获取数据 */
  const uncleState = useSelector((state) => {
    console.log(state, 66)
    return state.books
  })
  const userState = useSelector((state) => {
    console.log(state, 66)
    return state.user
  })
  // useSelector()===>store.getState()
  // useDispatch()===>store.dispatch()
  const handle2 = () => {
    // store.dispatch({ type: 'increment', payload: 5 })
    dispatch({ type: 'increment', payload: 5 })
    // console.log(store.getState(), 555)
  }
  return (
    <div>
      御剑乘风来,除魔天地间!==Uncle====react-redux:{uncleState}======
      {userState.age}==
      <button onClick={handle2}>Uncle-5</button>
    </div>
  )
}
export default Uncle
